refactor(logs): improve logs around deletions and permissions
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 17 Apr 2025 17:18:40 +0000 (19:18 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 24 Apr 2025 09:01:34 +0000 (11:01 +0200)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/common/filesystembase.cpp
src/libsync/filesystem.cpp

index 9cae216b0bac9f34abe8a25c285f5eba5be54e9e..c6dcb49d1c9d07b1ed1ce3253890bb83a614c11c 100644 (file)
@@ -550,6 +550,7 @@ bool FileSystem::remove(const QString &fileName, QString *errorString)
             qCWarning(lcFileSystem()) << "File is already deleted" << fileName;
             return false;
         }
+        qCInfo(lcFileSystem()) << "delete" << fileName;
     }
     catch (const std::filesystem::filesystem_error &e)
     {
index 002a031de3a5d66d8fa846aeefd1289f38a0b045..52e8f11ad6760e54c57a0edf2fe27d1e1ade17f8 100644 (file)
@@ -281,6 +281,7 @@ bool FileSystem::removeRecursively(const QString &path, const std::function<void
             const auto parentFolderPath = fileInfo.dir().absolutePath();
             const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
             removeOk = FileSystem::remove(di.filePath(), &removeError);
+            qCInfo(lcFileSystem()) << "delete" << di.filePath();
             if (removeOk) {
                 if (onDeleted)
                     onDeleted(di.filePath(), false);
@@ -304,6 +305,7 @@ bool FileSystem::removeRecursively(const QString &path, const std::function<void
         const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
         FileSystem::setFolderPermissions(path, FileSystem::FolderPermissions::ReadWrite);
         allRemoved = QDir().rmdir(path);
+        qCInfo(lcFileSystem()) << "delete" << path;
         if (allRemoved) {
             if (onDeleted)
                 onDeleted(path, true);
@@ -514,7 +516,7 @@ bool FileSystem::setFolderPermissions(const QString &path,
 bool FileSystem::isFolderReadOnly(const std::filesystem::path &path) noexcept
 {
 #ifdef Q_OS_WIN
-    qCInfo(lcFileSystem()) << "is it read-only folder:" << path.wstring().c_str();
+    qCInfo(lcFileSystem()) << "is it read-only folder:" << QString::fromStdWString(path.wstring());
 
     SECURITY_INFORMATION info = DACL_SECURITY_INFORMATION;
     std::unique_ptr<char[]> securityDescriptor;
@@ -569,7 +571,7 @@ bool FileSystem::isFolderReadOnly(const std::filesystem::path &path) noexcept
         const auto currentAceHeader = reinterpret_cast<PACE_HEADER>(currentAce);
 
         if ((ACCESS_DENIED_ACE_TYPE == (currentAceHeader->AceType & ACCESS_DENIED_ACE_TYPE))) {
-            qCInfo(lcFileSystem()) << "detected access denied ACL: assuming read-only folder:" << path.wstring().c_str();
+            qCInfo(lcFileSystem()) << "detected access denied ACL: assuming read-only folder:" << QString::fromStdWString(path.wstring());
             return true;
         }
     }